<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('活动咨询记录列表')" />
</head>

<body class="gray-bg">

     <div class="container-div">
        <div class="row">
            <!--    条件搜索模块-->
            <div class="col-sm-12 search-collapse">
                <!--    条件搜索表单-->
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <!--    下拉列表活动咨询处理状态条件选择-->
                            <li>
                                <p>状态：</p>
                                <select name="state" th:with="type=${@dict.getType('advice_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <!--    提交时间范围条件选择-->
                            <li class="select-time">
                                <p>反馈提交时间：</p>
                                <input type="text" class="time-input" id="startTime" style="width: 133px" placeholder="请选择开始时间" name="beginDate"/>
                                <span>至</span>
                                <input type="text" class="time-input" id="endTime" style="width: 133px" placeholder="请选择结束时间" name="endDate"/>
                            </li>
                            <!--    搜索按钮-->
                            <li>
                                <a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--    展示表格模块-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">
                    <thead>
                        <tr>
                            <th data-formatter="fm_rowIndex" data-align="center">序号</th>
                            <th data-field="volunteerId">志愿者编号</th>
                            <th data-field="volunteerName">姓名</th>
                            <th data-field="activityId">活动编号</th>
                            <th data-field="activityName">活动名称</th>
                            <th data-field="adviceContent">问题反馈内容</th>
                            <th data-field="adviceAnswer">应答内容</th>
                            <th data-field="createTime">提交时间</th>
                            <!--    用JS中的 fm_adviceState格式转化函数 对活动咨询处理状态进行转换-->
                            <th data-field="state" data-formatter="fm_adviceState">状态</th>
                            <!--    用JS中的 fm_commands 加载操作列中的按钮-->
                            <th data-formatter="fm_commands" data-width="120px" data-align="center">操作</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>

    <th:block th:include="include :: footer" />

    <!-- JS -->
    <script th:inline="javascript">
        /** 一些数据的初始化 */

        //  编辑按钮标志
        var editFlag = [[${@permission.hasPermi('vtsp:advice:edit')}]];
        //  请求路径访问前缀
        var prefix = ctx + "vtsp/advice";

        //  初始化函数
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "活动咨询记录",
                uniqueId: "adviceId"
            };
            $.table.init(options);
        });

        /** 字典功能 */
        //  advice_state字典数据内容
        let adviceState_data = [[${@dict.getType('advice_state')}]];
        //  fm_adviceState字典格式转化函数
        function fm_adviceState(value, row ,index) {
            return $.table.selectDictLabel(adviceState_data, value);
        }

        //  fm_commands，操作列命令
        function fm_commands(value, row, index){
            var actions = [];
            //  根据条件来选择操作列的按钮样式
            if(row.state === 0) {
                actions.push('<button class="btn btn-danger' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.adviceId + '\')"><i class="fa"></i>处理</button> ');
            }
            if(row.state === 1 || row.state === 2) {
                actions.push('<button class="btn btn-default' + editFlag + '" disabled="disabled" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.adviceId + '\')"><i class="fa"></i>处理</button> ');
            }
            return actions.join('');
        }

    </script>
</body>
</html>